package com.cc.sanjieduan.mapper;

import com.cc.sanjieduan.pojo.Device;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface DeviceMapper {
    @Select("select * from sys_device where device_id =#{deviceId}")
    Device selectBuId(String deviceId);

    @Insert("insert  into sys_device (device_id,device_name,categy_id,bind_user_id,scene_id,bind_time,is_online) VALUE (#{deviceId},#{deviceName},#{categyId},#{bindUserId},#{sceneId},#{bindTime},#{isOnline})")
    void addDevice(Device device);

    @Update("UPDATE sys_device SET is_online=#{isOnline},connect_time=#{connectTime},current_connect_ip=#{currentConnectIp} ,connect_location=#{connectLocation} WHERE device_id =#{deviceId}")
    void updateOnLine(Device device);

    @Update("UPDATE sys_device SET is_online=#{isOnline},lost_connect_time=#{lostConnectTime} WHERE device_id =#{deviceId}")
    void updateOffLine(Device device);
}
